package com.gpslw.mvc.bean;

public enum SexEnum {

    MAN(1, "男"),
    WOMAN(2, "女")
    ;

    private Integer code;

    private String desc;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    SexEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static SexEnum getSexByCode(Integer code){
        SexEnum[] values = SexEnum.values();
        for (SexEnum value : values) {
            if (value.getCode().equals(code)){
                return value;
            }
        }
        return null;
    }

    public String toString(SexEnum sexEnum){
        String result = "code:" + sexEnum.getCode() + ","
                + "desc:" + sexEnum.getCode();
        return result;
    }
}
